package com.widget

import android.content.Context

import android.os.Bundle

import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatDialog
import androidx.databinding.DataBindingUtil
import com.sh.doctors.cloud.BuildConfig
import com.sh.doctors.cloud.R

import com.sh.doctors.cloud.databinding.LoadingDialogBinding

/**
 * 页面描述：LoadingDialog  加载进度框
 *
 * Created by ditcr on 2017/11/15.
 */
class LoadingDialog(val mContext: Context, style: Int = R.style.LoadingDialog) : AppCompatDialog(mContext, style) {

    val mBinding: LoadingDialogBinding by lazy {
        DataBindingUtil.inflate<LoadingDialogBinding>(
            LayoutInflater.from(mContext),
            R.layout.loading_dialog, null, false
        )
    }

    init {
        setContentView(mBinding.root)
    }

    fun showMsg(msg: String? = null) {
        mBinding.warningTv.text = msg ?: mContext.getString(R.string.loading)
        show()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setCanceledOnTouchOutside(false)
        window!!.setWindowAnimations(android.R.style.Animation_Dialog)
    }

    override fun onBackPressed() {
        if (BuildConfig.DEBUG) {
            super.onBackPressed()
        }
    }

}